using System;
using System.Collections.Generic;
using System.Text;
using Utility;
using Entites;
using DAL;
namespace BUS
{
  public  class DealBUS
    {
        
         public static void Insert(Deal d)
        {
            DealDAL dDAL = new DealDAL();
           dDAL.Insert(d);
        }
        public static void Update(Deal d)
        {
            DealDAL dDAL = new DealDAL();
            dDAL.Update(d);
        }
        public static void Delete(int iD)
        {
            DealDAL dDAL = new DealDAL();
            dDAL.Delete(iD);
        }
        public static tbDealCollection Get(string where,
            int pageindex,
            int pagesize,
            string orderby,
            string orderdirection,
            out int total)
        {
            DealDAL dDAL = new DealDAL();
            return dDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbDealCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            DealDAL dDAL = new DealDAL();
            return dDAL.Get(cri.Criter, 0, 0, tbDealColumns.MaDeal.ToString(), OrderDirection.ASC.ToString(), out total);
        }
       public static Deal GetByID(int iD)
       {
           int total = 0;
           Criteria cri = new Criteria();
           cri.add(Condition.AND, tbDealColumns.MaDeal.ToString(), Condition.EQUAL, iD);
           DealDAL dDAL = new DealDAL();
           tbDealCollection dealcollection = dDAL.Get(cri.Criter,
                 0, 0, tbDealColumns.MaDeal.ToString(), OrderDirection.ASC.ToString(), out total);
           if (dealcollection.Count > 0)
               return dealcollection[0];
           return null;
       }
      
        public static tbDealCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            DealDAL dDAL = new DealDAL();
            return dDAL.Get(cri.Criter, 1, number,
             tbDealColumns.MaDeal.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbDealCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            DealDAL dDAL = new DealDAL();
            return dDAL.Get(cri.Criter, 1, number,
               tbDealColumns.MaDeal.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
    
    }

